  ##!/bin/bash
#
## 发送飞书信息接口
#url="https://open.feishu.cn/open-apis/bot/v2/hook/d526eae9-434c-4d61-86cf-74ddebd0ffdf"
#text="在干嘛"
#dataJson='{"msg_type":"text","content":{"text":"123\n123"}}'
#httpHeader='Content-Type: application/json'
#echo  "在干嘛"
#
#curl --location --request POST ${url} --header ${httpHeader} --data-raw ${dataJson}



#!/bin/bash

api=https://open.feishu.cn/open-apis/bot/v2/hook/d526eae9-434c-4d61-86cf-74ddebd0ffdf  #飞书机器人webhook 地址


#换行用\n 空格用\t
nowTime=$(date "+%Y-%m-%d %H:%M:%S")
MSG="中文字符"

app_id="cli_a4562ed834fed00d"
app_secret="3JdiAD54oxQP8hSsUUg6PgUuFTk0qgzx"

# 获取飞书access_token
token=$(curl -X POST -H "Content-Type: application/json; charset=utf-8" \
         -d '{
               "app_id": "cli_a4562ed834fed00d",
               "app_secret": "3JdiAD54oxQP8hSsUUg6PgUuFTk0qgzx"
              }' \
          https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal \
          |/c/Users/ASUS/Downloads/jq-win64.exe -r '.tenant_access_token')

printf $token

# 上传图片
imageData=$(curl -v --location --request POST 'https://open.feishu.cn/open-apis/im/v1/images' \
           --header 'Authorization: Bearer '$token \
           --header 'Content-Type: multipart/form-data' \
           --form 'image_type="message"' \
           --form 'image=@"./testCode.png"')


#imageKey=`echo "$imageData" | /c/Users/ASUS/Downloads/jq-win64.exe -r '.data.image_key'`
# 功能已完成，报错是没开通权限发送图片的权限，在飞书云里面申请开通
printf $imageData

# curl -v -X POST \
#  $api  \
#  -H "Content-type:application/json" \
#  -d  '{
#    "msg_type": "post",
#    "content": {
#        "post": {
#            "zh_cn": {
#                "title": "this is title",
#                "content": [
#                   [
#                      {"tag": "text", "text": "'"应用：${MSG}\n"'"},
#                      {"tag": "text", "text": "'"分支：22\n"'"},
#                      {"tag": "text", "text": "'"状态：成功\n"'"},
#                      {"tag": "text", "text": "'"构建："'"},
#                      {"tag": "text", "text": "'"日期：$nowTime\n"'"},
#                      {"tag": "img", "image_key": "'${imageKey}'"}
#                    ]
#                ]
#            }
#        }
#    }
#}'
